/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package general;

import java.sql.*;
import conexion.CConexion;
import validaciones.CLogin;

/**
 *
 * @author SISTEMAS
 */
public class CPerm100 extends CConexion {

    CLogin loginU = new CLogin();

    public CPerm100() {
        super();
    }

    public boolean buscarProgramaUsuario(String usuario,String compania,String programa) throws SQLException {
        //System.out.println(loginU.getUsuarioLogin());
        //System.out.println(programa);
        String sqlProgramas = "select * from use100 u,rol100 r,perm100 p where u.use100rol=r.rol100cdgo and r.rol100cdgo=p.rol100cdgo and u.use100logi='" + usuario + "' and u.use100nocia='" + compania + "' and p.pgr100cdgo='"+programa+"'";
        Statement stncProgramas = this.getConexion().createStatement();
        ResultSet rsProgramas = stncProgramas.executeQuery(sqlProgramas);
        if (rsProgramas.next()) {
            return true;
        } else {
            return false;
        }
    }
    
    public ResultSet buscarProgramasPorRol(String rol) throws SQLException {
        //System.out.println(loginU.getUsuarioLogin());
        //System.out.println(programa);
        String sqlProgramas = "select p.pgr100cdgo,pg.pgr100desc from perm100 p,pgr100 pg where p.pgr100cdgo=pg.pgr100cdgo and p.rol100cdgo='" + rol + "' and p.perm100nocia='" + loginU.getCompaniaActual() + "'";
        Statement stncProgramas = this.getConexion().createStatement();
        ResultSet rsProgramas = stncProgramas.executeQuery(sqlProgramas);
        return rsProgramas;        
        
    }
}
